<template>
	<view class="page">
		<view class="tongzhi_box">
			<uni-notice-bar text="[优先须知] 关于界面设计理念,与系统[积分]解释。点击了解*" class="tongzhi_1" @click='go_jie_mian_she_ji' ></uni-notice-bar>
			<uni-notice-bar scrollable="true" single="true" class="tongzhi_2"  text="[报名须知] 切勿重复填报数据,以免数据重复丢失。"></uni-notice-bar>
		</view>

		<view class="lunbo_box">
			<swiper indicator-dots="true" autoplay="true" interval="3000" duration="1000" circular>
				<swiper-item>
					<!-- <view class="swiper-item">A1</view> -->
					<image class="swiper-item" src="../../static/swipe/1.jpg" mode="aspectFill"></image>
				</swiper-item>
				<swiper-item>
					<!-- <view class="swiper-item">B1</view> -->
					<image class="swiper-item" src="../../static/swipe/2.jpg" mode="aspectFill"></image>
				</swiper-item>
				<swiper-item>
					<!-- <view class="swiper-item">C1</view> -->
					<image class="swiper-item" src="../../static/swipe/3.jpg" mode="aspectFill"></image>
				</swiper-item>
			</swiper>
		</view>

		<view class="fenlei_box">
			<button type="primary" plain="true" class="jiaofei" open-type="getUserInfo" @getuserinfo="mpGetUserInfo" >我要缴费积分！</button>
			<button type="primary" plain="true" class="chaxun_jiaofei" @click="goChaXunJiaoFei">查询积分缴费情况.</button>
			<button type="primary" plain="true" class="chaxun_jiaofei"  @click="gofuwenben" >富文本编辑器测试</button>
			<button type="primary" plain="true" class="chaxun_jiaofei"  @click="go_nianjing" >查询我的年金积分</button>
		</view>
	</view>
</template>

<script>
	import uniNoticeBar from '../../components/uni-notice-bar/uni-notice-bar.vue'
	export default {
		data() {
			return {
				title: '空间魔方'
			}
		},
		methods: {
			goJiaoFei(e) {
				console.log(e);
				uni.showLoading({
					mask: false,
					title: '获取服务器中...'
				});
				
				setTimeout(function() {
					uni.hideLoading();
					uni.navigateTo({
						url: '../jiaoFei_d1/jiaoFei_d1?name=' + encodeURIComponent(JSON.stringify('我是&传递&信息！')),
					});
				}, 2000);
				
			},
			goChaXunJiaoFei(e) {
				uni.hideLoading();
			},
			gogoweixing(e) {
				//微信登陆
				uni.login({
					provider: 'weixin',
					success: function(loginRes) {
						console.log("gogoweixing=")
						console.log(loginRes);
					}
				});
			},
			getUserInfo() {
				//必须这样访问微信用户数据，不能以前那样直接弹出！
				uni.getUserInfo({
					provider: 'weixin',
					success: (result) => {
						console.log('getUserInfo success', result);
					},
					fail: (error) => {
						console.log('getUserInfo fail', error);
					}
				});
			},
			mpGetUserInfo(result) {
				this.gogoweixing();
				if (result.detail.errMsg !== 'getUserInfo:ok') {
					uni.showModal({
						title: '登录失败',
						content: '错误原因' + result.detail.errMsg+'   '+'请确保点击确认授权登陆！',
						showCancel: false
					});      
					return;
				}else{
					console.log("成功！微信登陆！");
					console.log(result);
					//授权登陆成功后,跳转缴费页面
					this.goJiaoFei();
				}

			},
			gofuwenben(e){
				uni.navigateTo({
					url:'../fuWenBen/fuWenBen'
				})
			},
			go_nianjing(e){
				uni.navigateTo({
					url:'../cy_nianjing_y1/cy_nianjing_y1'
				})
			},
			go_jie_mian_she_ji(e){
				uni.navigateTo({
					url:'../jie_mian_she_ji/jie_mian_she_ji'
				})
			}
		},
		components: {
			uniNoticeBar
		},
		onLoad() {
			//不建议直接访问微信用户
			// uni.login({
			// 	provider: 'weixin',
			// 	success: function(loginRes) {
			// 		console.log(loginRes);
			// 	}
			// });
		}
	}
</script>

<style>
	@import url("index.css");
</style>
